import PySimpleGUI as sg

# 公共基础参数
pub_layout = [
    [sg.Text("   利率(i)  "), sg.Text("   折现率(r)   "), sg.Text("  最低资本回报率(MARR)   ")],
    [sg.InputText("0.0435", key="PUB_I_INPUT-", size=(10, 1)),
     sg.InputText("0.06", key="PUB_R_INPUT-", size=(10, 1)),
     sg.InputText("0.09", key="PUB_MARR_INPUT-", size=(10, 1)), ],
    [sg.Text(" (以小数形式输入,如输入0.0435表示3% ) ")],
    [sg.Text(" ", font=("Microsoft YaHei", 14))],
    [sg.Text("请点击左上角[文件]->[导入Excel] 导入数据.", font=("Microsoft YaHei", 16))]
]

pub_i = 0.0435
pub_r = 0.06
pub_marr = 0.09


def read_pub_values(values):
    # 全局变量
    global pub_i, pub_r, pub_marr
    pub_i = float(values["PUB_I_INPUT-"])
    pub_r = float(values["PUB_R_INPUT-"])
    pub_marr = float(values["PUB_MARR_INPUT-"])


# 绑定事件
def bind_events(window):
    window['PUB_I_INPUT-'].bind('<KeyRelease>', '_KEY_RELEASE')
    window['PUB_R_INPUT-'].bind('<KeyRelease>', '_KEY_RELEASE')
    window['PUB_MARR_INPUT-'].bind('<KeyRelease>', '_KEY_RELEASE')
